﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ContentEdit.aspx.cs" MasterPageFile="~/Home.Master"
    Inherits="SLIITPro.SysUsers.ContentEdit" Title="Content Edit Page" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="itemContent" runat="server" ContentPlaceHolderID="BodyContentPlaceHolder">
    <table>
        <tr>
            <td>
            </td>
        </tr>
        <tr>
            <td>
            </td>
        </tr>
    </table>
    <div class="grid">
        <div class="rounded">
            <div class="top-outer">
                <div class="top-inner">
                    <div class="top">
                        <h2>
                            Business List Edit</h2>
                    </div>
                </div>
            </div>
            <div class="mid-outer">
                <div class="mid-inner">
                    <div class="mid">
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <asp:GridView ID="grdContent" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="BId"
                                    OnPageIndexChanging="grdContent_IndexChanging" runat="server" GridLines="None"
                                    OnSelectedIndexChanged="grdContent_SelectedIndexChanged" CssClass="datatable">
                                    <Columns>
                                        <asp:TemplateField ItemStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkDelete" runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="BId" HeaderText="Id" InsertVisible="False" ReadOnly="True" />
                                        <asp:BoundField DataField="BName" HeaderText="Business Name" />
                                        <asp:BoundField DataField="BCity" HeaderText="City" />
                                        <asp:BoundField DataField="BStreet" HeaderText="Street" />
                                        <asp:BoundField DataField="BCountry" HeaderText="Country" />
                                        <asp:BoundField DataField="BEmail" HeaderText="Email" />
                                        <asp:BoundField DataField="BWeb" HeaderText="Web" />
                                        <asp:BoundField DataField="BType" HeaderText="Business Type" />
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <asp:LinkButton ID="btnViewDetails" runat="server" Text="Edit" CommandName="Select" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <PagerStyle CssClass="pager-row" />
                                    <RowStyle CssClass="row" />
                                                               </asp:GridView>
                                <div class="buttondiv">
                                    <asp:Button ID="btnSelectAll" runat="server" Text="Select All" CssClass="cssbutton"
                                        Width="75px" OnClick="btnSelectAll_Click" />
                                    <asp:Button ID="btnMultiDelete" runat="server" Text="Delete" CssClass="cssbutton"
                                        Width="75px" OnClientClick="return confirm('Are you sure want to delete this record?');"
                                        OnClick="btnMultiDelete_Click" />
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                </div>
            </div>
            <div class="bottom-outer">
                <div class="bottom-inner">
                    <div class="bottom">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <asp:SqlDataSource ID="SqlDataSourceDetails" runat="server" ConnectionString="<%$ ConnectionStrings:SLIITProConnectionString %>"
        OnSelecting="SqlDataSourceDetails_Selecting" SelectCommand="SELECT [BId], [BName], [BStreet], [BCity], [BCountry], [BPhone], [BWeb], [BEmail], [BType], [BCreatedAt], [BUpdatedAt], [BImageFolderID] FROM [BusinessItem] WHERE ([BId] = @BId)"
        DeleteCommand="DELETE FROM [BusinessItem] WHERE [BId] = @BId" UpdateCommand="UPDATE [BusinessItem] SET [BName] = @BName, [BStreet] = @BStreet, [BCity] = @BCity, [BCountry] = @BCountry, [BPhone] = @BPhone, [BWeb] = @BWeb, [BEmail] = @BEmail, [BType] = @BType, [BUpdatedAt] = @BUpdatedAt WHERE [BId] = @BId">
        <DeleteParameters>
            <asp:Parameter Name="BId" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="BName" Type="String" />
            <asp:Parameter Name="BStreet" Type="String" />
            <asp:Parameter Name="BCity" Type="String" />
            <asp:Parameter Name="BCountry" Type="String" />
            <asp:Parameter Name="BPhone" Type="String" />
            <asp:Parameter Name="BWeb" Type="String" />
            <asp:Parameter Name="BEmail" Type="String" />
            <asp:Parameter Name="BType" Type="String" />
            <asp:Parameter Name="BUpdatedAt" Type="DateTime" />
            <asp:Parameter Name="BId" Type="Int32" />
        </UpdateParameters>
        <SelectParameters>
            <asp:Parameter Name="BId" Type="Int16" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:Panel ID="pnlPopup" runat="server" CssClass="detail" Width="500px" Style="display: none">
        <asp:UpdatePanel ID="updPnlBusinessDetail" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
                <cc1:ModalPopupExtender ID="mdlPopup" runat="server" TargetControlID="btnShowPopup"
                    PopupControlID="pnlPopup" CancelControlID="btnClose" BackgroundCssClass="modalBackground"
                    Enabled="true" />
                <asp:DetailsView ID="dvBusinessDetail" runat="server" DataSourceID="SqlDataSourceDetails"
                    CssClass="detailgrid" GridLines="None" DefaultMode="Edit" AutoGenerateRows="False"
                    Visible="False" Width="100%" DataKeyNames="BId">
                    <HeaderStyle CssClass="headerstyle" />
                    <HeaderTemplate>
                        <asp:Label ID="lblHeader" runat="server" Text='<%# Bind("BName") %>' Font-Bold="true"
                            Font-Size="Larger"></asp:Label>
                    </HeaderTemplate>
                    <Fields>
                        <asp:BoundField DataField="BId" HeaderText="BId" InsertVisible="False" ReadOnly="True"
                            SortExpression="BId" />
                        <asp:TemplateField HeaderText="Business Name">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtName" runat="server" Text='<%# Bind("BName") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfBName" runat="server" ControlToValidate="txtName"
                                    Display="Dynamic" ErrorMessage="Required" ValidationGroup="details"></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="City">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtCity" runat="server" Text='<%# Bind("BCity") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfBCity" runat="server" ControlToValidate="txtCity"
                                    Display="Dynamic" ErrorMessage="Required" ValidationGroup="details"></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Address">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtAddress" runat="server" Text='<%# Bind("BStreet") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfBAddress" runat="server" ControlToValidate="txtAddress"
                                    Display="Dynamic" ErrorMessage="Required" ValidationGroup="details"></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Country">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtCountry" runat="server" Text='<%# Bind("BCountry") %>'></asp:TextBox>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Phone">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtPhone" runat="server" Text='<%# Bind("BPhone") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfBPhone" runat="server" ControlToValidate="txtPhone"
                                    Display="Dynamic" ErrorMessage="Required" ValidationGroup="details"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="regPhone" runat="server" ControlToValidate="txtPhone"
                                    Display="Dynamic" ErrorMessage="&lt;br /&gt;Please enter a phone number in the format:&lt;br /&gt;+94xxxxxxxxx"
                                    ValidationExpression="^[+][0-9]\d{2}[0-9]\d{7}" ValidationGroup="details"></asp:RegularExpressionValidator>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Web Address">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtWeb" runat="server" Text='<%# Bind("BWeb") %>'></asp:TextBox>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Email">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtEmail" runat="server" Text='<%# Bind("BEmail") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfBEmail" runat="server" ControlToValidate="txtEmail"
                                    Display="Dynamic" ErrorMessage="Required" ValidationGroup="details"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="regBEmail" runat="server" ControlToValidate="txtEmail"
                                    Display="Dynamic" ErrorMessage="&lt;br /&gt;Please enter a Email address in the format:&lt;br /&gt;name@yourdomian.com"
                                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ValidationGroup="details"></asp:RegularExpressionValidator>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Business Type">
                            <EditItemTemplate>
                                <asp:TextBox ID="txtBtype" runat="server" Text='<%# Bind("BType") %>'></asp:TextBox>
                            </EditItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Last Updated">
                            <EditItemTemplate>
                                <asp:Label ID="lblUpdate" runat="server" Text='<%# Bind("BUpdatedAt") %>'></asp:Label>
                            </EditItemTemplate>
                        </asp:TemplateField>
                    </Fields>
                </asp:DetailsView>
                <div class="footer">
                    <asp:Button ID="btnDelete" runat="server" Text="Delete" CssClass="cssbutton" Width="75px"
                        OnClientClick="return confirm('Are you sure wants to delete this record?');"
                        ValidationGroup="details" CausesValidation="true" />
                    <asp:Button ID="btnSave" runat="server" Text="Save" CssClass="cssbutton" Width="75px"
                        ValidationGroup="details" CausesValidation="true" />
                    <asp:Button ID="btnClose" runat="server" Text="Close" CssClass="cssbutton" Width="75px"
                        CausesValidation="false" />
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
</asp:Content>
